package cn.com.surker.interceptor;

import cn.com.surker.workcon.service.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 装载对接工控数据的实现类
 * @author luotao
 * @date 2025/3/5
 */
@Configuration
public class WorkConImplConfig {

	@Value("${control.impl.package}")
	private String workConImplPackage;

	@Bean
	public DosageService dosageServiceImpl() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
		String className = "cn.com.surker.workcon.service." + workConImplPackage + ".DosageServiceImpl";
		Class<?> aClass = Class.forName(className);
		Object o = aClass.newInstance();
		DosageService bean = (DosageService) o;
		return bean;
	}

	@Bean
	public ManualService manualServiceImpl() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
		String className = "cn.com.surker.workcon.service." + workConImplPackage + ".ManualServiceImpl";
		Class<?> aClass = Class.forName(className);
		Object o = aClass.newInstance();
		ManualService bean = (ManualService) o;
		return bean;
	}

	@Bean
	public PieceService pieceServiceImpl() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
		String className = "cn.com.surker.workcon.service." + workConImplPackage + ".PieceServiceImpl";
		Class<?> aClass = Class.forName(className);
		Object o = aClass.newInstance();
		PieceService bean = (PieceService) o;
		return bean;
	}

	@Bean
	public ProdDelService prodDelServiceImpl() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
		String className = "cn.com.surker.workcon.service." + workConImplPackage + ".ProdDelServiceImpl";
		Class<?> aClass = Class.forName(className);
		Object o = aClass.newInstance();
		ProdDelService bean = (ProdDelService) o;
		return bean;
	}

	@Bean
	public ProduceService produceServiceImpl() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
		String className = "cn.com.surker.workcon.service." + workConImplPackage + ".ProduceServiceImpl";
		Class<?> aClass = Class.forName(className);
		Object o = aClass.newInstance();
		ProduceService bean = (ProduceService) o;
		return bean;
	}

	@Bean
	public ProductService productServiceImpl() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
		String className = "cn.com.surker.workcon.service." + workConImplPackage + ".ProductServiceImpl";
		Class<?> aClass = Class.forName(className);
		Object o = aClass.newInstance();
		ProductService bean = (ProductService) o;
		return bean;
	}

	@Bean
	public RecipeService recipeServiceImpl() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
		String className = "cn.com.surker.workcon.service." + workConImplPackage + ".RecipeServiceImpl";
		Class<?> aClass = Class.forName(className);
		Object o = aClass.newInstance();
		RecipeService bean = (RecipeService) o;
		return bean;
	}

	@Bean
	public StorERPMaterService storERPMaterServiceImpl() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
		String className = "cn.com.surker.workcon.service." + workConImplPackage + ".StorERPMaterServiceImpl";
		Class<?> aClass = Class.forName(className);
		Object o = aClass.newInstance();
		StorERPMaterService bean = (StorERPMaterService) o;
		return bean;
	}

	@Bean
	public StorXMaterService storXMaterServiceImpl() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
		String className = "cn.com.surker.workcon.service." + workConImplPackage + ".StorXMaterServiceImpl";
		Class<?> aClass = Class.forName(className);
		Object o = aClass.newInstance();
		StorXMaterService bean = (StorXMaterService) o;
		return bean;
	}

	@Bean
	public TaskService taskServiceImpl() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
		String className = "cn.com.surker.workcon.service." + workConImplPackage + ".TaskServiceImpl";
		Class<?> aClass = Class.forName(className);
		Object o = aClass.newInstance();
		TaskService bean = (TaskService) o;
		return bean;
	}
}
